#!/usr/bin/env python
# -*- coding: utf-8 -*-

# @Time     :2020/10/12
# @Author   :Changshu
# @File     :practice_257.py
# 257. 二叉树的所有路径

# 给定一个二叉树，返回所有从根节点到叶子节点的路径。
'''深度优先'''
class TreeNode:
	def __init__(self,x):
		self.val=x
		self.left=None
		self.right=None


def binaryTreePaths(root: TreeNode) -> list:



	def constructPaths(root:TreeNode,path:list):
		if root:
			path+=str(root.val)
			if not root.left and not root.right:
				paths.append(path)
			else:
				path+='->'
				constructPaths(root.left,path)
				constructPaths(root.right, path)
	paths=[]
	constructPaths(root,'')
	return paths

